package cn.admin.configcenter.configservice.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RequestResponseUtil {

    public static String getRemoteIp(HttpServletRequest request) {
        String nginxHeader = request.getHeader("X-Real-IP");
        return nginxHeader == null ? request.getRemoteAddr() : nginxHeader;
    }

    public static void setCommonResponseHeaders(HttpServletResponse response) {
        response.setHeader("Pragma", "no-cache");
        response.setDateHeader("Expires", 0L);
        response.setHeader("Cache-Control", "no-cache,no-store");
    }

}
